// jack

//跨域web服务调用
function JKjsonP(pobj){
	var pdt = {};
	if (typeof pobj.parameter != "undefined") {
		pdt = pobj.parameter;
	}
	$.ajax({
		   type: "POST",
		   url: "http://122.144.131.13:8088/jkstore/"+pobj.ws+"?jsoncallback=?",
		   dataType: "jsonp",
		   data: pdt,
		   success: function(rt){
		     	var json=eval(rt);
		        if(typeof pobj.sFunc =="function"){
					pobj.sFunc(json,rt);
				}
		   },
		   error: function (XMLHttpRequest, textStatus, errorThrown) {
		        if(typeof pobj.eFunc =="function"){
					pobj.eFunc(XMLHttpRequest, textStatus, errorThrown.message);
				}
		   }
		});	
}

function JKPprompt(vid,txt,vtime,vth){
	$( vid ).find("p").html(txt).end().popup("open",{ positionTo: "window",transition: "pop",theme: (typeof vth=="undefined")?"b":vth });
	window.setTimeout(function(){$(vid).popup( "close" );},(typeof vtime=="undefined")?2000:vtime);
	}

function JKChangePage(vid,vtr,vchs){
	$.mobile.changePage(vid, { transition: vtr},(typeof vchs=="undefined")?true:vchs );
	}
	
//判断一维数组或对象是否包含指定元素，如果没有返回-1
Array.prototype.contains = function (element) {
    for (var i = 0; i < this.length; i++) {
        if (typeof element == "object") {
            if (this[i].equals(element)) {
                return i;
            }
        } else {
            if (this[i] == element) {
                return i;
            }
        }
    }
    return -1;
};

//去掉字符串首位空格
String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
//HTML编码
String.prototype.HTMLEnCode = function () {
    return this.replace("'","&#39;").replace("\"","&quot;").replace("<","&lt;").replace(">","&gt;");
}
//HTML解码
String.prototype.HTMLDeCode = function () {
    return this.replace("&#39;","'").replace("&quot;","\"").replace("&lt;","<").replace("&gt;",">");
}
